package com.foodie.servlet;

import com.foodie.entity.Menu;
import com.foodie.service.MenuService;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/cre")
public class MenuServlet extends HttpServlet {
    MenuService menuService = new MenuService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Menu> menuList = menuService.menuList();
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().println(new Gson().toJson(menuList));
        System.out.println(menuList);
    }
}
